// 任务管理 - 所有任务数据都在这里统一管理
import type { Task } from '../types/task';

export const taskData: Task[] = [
  {
    id: 1,
    code: 'TASK-001',
    title: '用户登录页面开发',
    description: '开发用户登录页面，包括表单验证和样式设计',
    type: '功能开发',
    project: 'KZ-DevOps平台',
    status: '已完成',
    priority: '高',
    assignee: '李四',
    reporter: '张三',
    progress: 100,
    estimatedHours: 16,
    actualHours: 14,
    deadline: '2024-01-10',
    createdAt: '2024-01-01',
    updatedAt: '2024-01-10',
    tags: ['前端', '登录', 'UI'],
    attachments: [],
    relatedRequirement: 'REQ-001'
  },
  {
    id: 2,
    code: 'TASK-002',
    title: '项目管理API接口开发',
    description: '开发项目管理相关的RESTful API接口',
    type: '功能开发',
    project: 'KZ-DevOps平台',
    status: '进行中',
    priority: '高',
    assignee: '王五',
    reporter: '张三',
    progress: 70,
    estimatedHours: 24,
    actualHours: 17,
    deadline: '2024-01-25',
    createdAt: '2024-01-05',
    updatedAt: '2024-01-20',
    tags: ['后端', 'API', 'REST'],
    attachments: [],
    relatedRequirement: 'REQ-002'
  },
  {
    id: 3,
    code: 'TASK-003',
    title: '登录功能性能优化',
    description: '优化用户登录功能的响应时间和资源消耗',
    type: '性能优化',
    project: 'KZ-DevOps平台',
    status: '待测试',
    priority: '中',
    assignee: '赵六',
    reporter: '李四',
    progress: 90,
    estimatedHours: 8,
    actualHours: 7,
    deadline: '2024-01-30',
    createdAt: '2024-01-15',
    updatedAt: '2024-01-25',
    tags: ['性能', '优化', '后端'],
    attachments: [],
    relatedRequirement: 'REQ-001'
  },
  {
    id: 4,
    code: 'TASK-004',
    title: '用户权限管理文档编写',
    description: '编写用户权限管理模块的使用文档和API文档',
    type: '文档编写',
    project: 'KZ-DevOps平台',
    status: '待处理',
    priority: '中',
    assignee: '钱七',
    reporter: '王五',
    progress: 0,
    estimatedHours: 12,
    actualHours: 0,
    deadline: '2024-02-05',
    createdAt: '2024-01-20',
    updatedAt: '2024-01-20',
    tags: ['文档', '权限', 'API'],
    attachments: [],
    relatedRequirement: 'REQ-005'
  },
  {
    id: 5,
    code: 'TASK-005',
    title: '登录页面样式修复',
    description: '修复登录页面在移动端的样式显示问题',
    type: '缺陷修复',
    project: 'KZ-DevOps平台',
    status: '进行中',
    priority: '紧急',
    assignee: '李四',
    reporter: '张三',
    progress: 50,
    estimatedHours: 4,
    actualHours: 2,
    deadline: '2024-01-28',
    createdAt: '2024-01-22',
    updatedAt: '2024-01-25',
    tags: ['前端', '样式', '移动端'],
    attachments: [],
    relatedRequirement: 'REQ-001'
  }
];

// 生成更多测试数据
for (let i = 6; i <= 50; i++) {
  const types: Array<'功能开发' | '缺陷修复' | '性能优化' | '文档编写' | '测试任务'> = ['功能开发', '缺陷修复', '性能优化', '文档编写', '测试任务'];
  const projects = ['KZ-DevOps平台', 'CRM系统', 'ERP系统', 'OA系统'];
  const statuses: Array<'待处理' | '进行中' | '待测试' | '待验收' | '已完成' | '已取消'> = ['待处理', '进行中', '待测试', '待验收', '已完成', '已取消'];
  const priorities: Array<'低' | '中' | '高' | '紧急'> = ['低', '中', '高', '紧急'];
  const assignees = ['张三', '李四', '王五', '赵六', '钱七'];
  const reporters = ['张三', '李四', '王五', '赵六', '钱七'];
  
  taskData.push({
    id: i,
    code: `TASK-${i.toString().padStart(3, '0')}`,
    title: `任务标题${i}`,
    description: `这是第${i}个任务的详细描述`,
    type: types[Math.floor(Math.random() * types.length)],
    project: projects[Math.floor(Math.random() * projects.length)],
    status: statuses[Math.floor(Math.random() * statuses.length)],
    priority: priorities[Math.floor(Math.random() * priorities.length)],
    assignee: assignees[Math.floor(Math.random() * assignees.length)],
    reporter: reporters[Math.floor(Math.random() * reporters.length)],
    progress: Math.floor(Math.random() * 101),
    estimatedHours: Math.floor(Math.random() * 40) + 4,
    actualHours: Math.floor(Math.random() * 35),
    deadline: `2024-${(Math.floor(Math.random() * 12) + 1).toString().padStart(2, '0')}-${(Math.floor(Math.random() * 28) + 1).toString().padStart(2, '0')}`,
    createdAt: `2024-${(Math.floor(Math.random() * 12) + 1).toString().padStart(2, '0')}-${(Math.floor(Math.random() * 28) + 1).toString().padStart(2, '0')}`,
    updatedAt: `2024-${(Math.floor(Math.random() * 12) + 1).toString().padStart(2, '0')}-${(Math.floor(Math.random() * 28) + 1).toString().padStart(2, '0')}`,
    tags: ['标签1', '标签2', '标签3'],
    attachments: [],
    relatedRequirement: `REQ-${Math.floor(Math.random() * 50) + 1}`
  });
}

// 任务状态分布数据
export const taskStatusData = {
  labels: ['待处理', '进行中', '待测试', '待验收', '已完成', '已取消'],
  datasets: [
    {
      data: [
        taskData.filter(t => t.status === '待处理').length,
        taskData.filter(t => t.status === '进行中').length,
        taskData.filter(t => t.status === '待测试').length,
        taskData.filter(t => t.status === '待验收').length,
        taskData.filter(t => t.status === '已完成').length,
        taskData.filter(t => t.status === '已取消').length
      ],
      backgroundColor: [
        '#9CA3AF', // 待处理 - 灰色
        '#3B82F6', // 进行中 - 蓝色
        '#F59E0B', // 待测试 - 黄色
        '#8B5CF6', // 待验收 - 紫色
        '#10B981', // 已完成 - 绿色
        '#EF4444'  // 已取消 - 红色
      ]
    }
  ]
};

// 任务类型分布数据
export const taskTypeData = {
  labels: ['功能开发', '缺陷修复', '性能优化', '文档编写', '测试任务'],
  datasets: [
    {
      data: [
        taskData.filter(t => t.type === '功能开发').length,
        taskData.filter(t => t.type === '缺陷修复').length,
        taskData.filter(t => t.type === '性能优化').length,
        taskData.filter(t => t.type === '文档编写').length,
        taskData.filter(t => t.type === '测试任务').length
      ],
      backgroundColor: [
        '#3B82F6', // 功能开发 - 蓝色
        '#EF4444', // 缺陷修复 - 红色
        '#F59E0B', // 性能优化 - 黄色
        '#10B981', // 文档编写 - 绿色
        '#8B5CF6'  // 测试任务 - 紫色
      ]
    }
  ]
};

// 任务看板数据
export const taskBoardData = {
  columns: [
    {
      id: 'todo',
      title: '待处理',
      status: '待处理',
      tasks: taskData.filter(t => t.status === '待处理')
    },
    {
      id: 'in-progress',
      title: '进行中',
      status: '进行中',
      tasks: taskData.filter(t => t.status === '进行中')
    },
    {
      id: 'testing',
      title: '待测试',
      status: '待测试',
      tasks: taskData.filter(t => t.status === '待测试')
    },
    {
      id: 'review',
      title: '待验收',
      status: '待验收',
      tasks: taskData.filter(t => t.status === '待验收')
    },
    {
      id: 'done',
      title: '已完成',
      status: '已完成',
      tasks: taskData.filter(t => t.status === '已完成')
    }
  ]
};